package com.stsdai.order.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.abel533.mapper.Mapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.stsdai.common.pojo.StsdaiResult;
import com.stsdai.manager.pojo.OrderItem;
import com.stsdai.order.service.OrderItemService;

@Service
public class OrderItemServiceImpl implements OrderItemService {

	@Autowired
	private Mapper<OrderItem> mapper;
	
	@Override
	public StsdaiResult<OrderItem> queryOrderItemByShopId(Long shopid, Integer page, Integer rows) {
		// TODO Auto-generated method stub
		// 设置分页数据
		PageHelper.startPage(page, rows);
		// 设置查询条件
		OrderItem orderItem = new OrderItem();
		orderItem.setShopId(shopid);
		// 执行查询                                            
		List<OrderItem> list = this.mapper.select(orderItem);
		
		// 封装返回对象
		StsdaiResult<OrderItem> stsdaiResult = new StsdaiResult<>();
		
		// 设置结果集rows
		stsdaiResult.setRows(list);
		// 设置总记录数total
		PageInfo<OrderItem> pageInfo = new PageInfo<>(list);
		stsdaiResult.setTotal(pageInfo.getTotal());
		
		return stsdaiResult;
	}

}
